<!DOCTYPE html>
<html>
<head>
		<meta charset='utf-8'>
    <title>the5fire.com-backbone.js-Hello World</title>
</head>
<body>
    <button id="check">新手报到</button>
    <button id="btnDel">删掉</button>
    <input type="text" id="ttt">
    <ul id="world-list">
    </ul>

    <script src="js/jquery-2.2.2.min.js"></script>
    <script src="js/underscore.js"></script>
    <script src="js/backbone.js"></script>
    <script>
			$(function(){
					var Book = Backbone.Model.extend({				
				    defaults : {
				        title:'default'
				    },						
				    initialize: function(){
				        //alert('Hey, you create me!');
				    },
				    aboutMe:function(){
				    	 alert('我叫张三丰');	
				    }
				
				});
				
				var BookShelf = Backbone.Collection.extend({
				    model : Book
				});
				
				var book1 = new Book({title : 'book1'});
				var book2 = new Book({title : 'book2'});
				var book3 = new Book({title : 'book3'});
				
				//注意这里面是数组,或者使用add
				//var bookShelf = new BookShelf([book1, book2, book3]);
				
				var bookShelf = new BookShelf;
				
				bookShelf.add(book1);
				bookShelf.add(book2);
				bookShelf.add(book3);
				bookShelf.remove(book3);
				
				
				//基于underscore这个js库，还可以使用each的方法获取collection中的数据
				
				bookShelf.each(function(book){
				    alert(book.get('title'));
				});
			});   
    </script>
</body>
</html>